import { Post } from '@/utils/request.ts'
import {
  reqGetMemberParams,
  reqMemberBody,
  reqMemberRoleBody,
  respMemberData,
} from '@/pages/topic/api/types/member.ts'
import { respCommonList } from '@/api/types/common'

export enum API {
  ADD_MEMBER_URL = '/bioinfor/sg/back/member/createMember',
  EDIT_MEMBER_URL = '/bioinfor/sg/back/member/modifyMember',
  DELETE_MEMBER_URL = '/bioinfor/sg/back/member/removeMember',

  ADD_MEMBER_ROLE_URL = '/bioinfor/sg/back/member/createRole',
  MEMBER_LIST_PAGE_URL = '/bioinfor/sg/back/member/queryEditMemberPage',

  MEMBER_ROLE_LIST_URL = '/bioinfor/sg/back/member/queryRoleList',
}

export const reqGetMemberListPage = (reqData: reqGetMemberParams) =>
  Post<respCommonList<respMemberData[]>>(API.MEMBER_LIST_PAGE_URL, reqData)

// 添加成员
export const reqCreateMember = (reqData: reqMemberBody) =>
  Post<string>(API.ADD_MEMBER_URL, reqData)
// 编辑成员
export const reqUpdateMember = (reqData: reqMemberBody) =>
  Post<string>(API.EDIT_MEMBER_URL, reqData)

// 删除成员
export const reqDeleteMember = (id: string) =>
  Post<string>(API.DELETE_MEMBER_URL, { id })

// 添加角色
export const reqCreateMemberRole = (reqData: reqMemberRoleBody) =>
  Post<string>(API.ADD_MEMBER_ROLE_URL, reqData)

export const reqQueryRoleList = (id: number) =>
  Post(API.MEMBER_ROLE_LIST_URL, { id })
